/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import org.jfonia.images.ImageConstants;
import org.jfonia.images.ScaledImageIcon;
import org.jfonia.language.DescriptionConstants;
import org.jfonia.language.LabelConstants;
import org.jfonia.language.LanguageResource;
import org.jfonia.model.Sequence;
import org.jfonia.model.Staff;
import org.jfonia.model.elements.Beat;
import org.jfonia.model.elements.Clef;
import org.jfonia.model.elements.KeySignature;
import org.jfonia.model.elements.TimeSignature;
import org.jfonia.model.elements.Tone;
import org.jfonia.view.main.Project;

/**
 *
 * @author Rik Bauwens
 */
public class CreateStaffPartAction extends AbstractAction
{
        protected CreateStaffPartAction(int iconMaxSize)
        {
                super(LanguageResource.getInstance().getLabel(LabelConstants.STAFF_PART),
                      new ScaledImageIcon(ImageConstants.STAFF_PART,
                      LanguageResource.getInstance().getDescription(DescriptionConstants.STAFF_PART))
                      .setMaximumSide(iconMaxSize).getImageIcon());
        }

        public void actionPerformed(ActionEvent e)
        {
                Staff staff = new Staff();
                Sequence<Clef> clefSequence = new Sequence<Clef>(Clef.class);
                Sequence<KeySignature> keySignatureSequence = new Sequence<KeySignature>(KeySignature.class);
                Sequence<TimeSignature> timeSignatureSequence = new Sequence<TimeSignature>(TimeSignature.class);
                Sequence<Tone> toneSequence = new Sequence<Tone>(Tone.class);
                Sequence<Beat> beatSequence = new Sequence<Beat>(Beat.class);
                staff.addSequence(clefSequence);
                staff.addSequence(keySignatureSequence);
                staff.addSequence(timeSignatureSequence);
                staff.addSequence(toneSequence);
                staff.addSequence(beatSequence);
                clefSequence.add(new Clef());
                keySignatureSequence.add(new KeySignature());
                timeSignatureSequence.add(new TimeSignature());
                toneSequence.add(new Tone());
                beatSequence.add(new Beat());
                Project.getInstance().getCurrentLeadSheet().getStaffCollection().addStaff(staff);
        }
}